package uk.co.q3c.deplan.client.domain.resource;

import uk.co.q3c.deplan.client.domain.util.DateProfileEntryBase;

import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.Unindexed;

@Unindexed
@Cached(expirationSeconds = 600)
public class ResourceProfileEntry extends DateProfileEntryBase {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 
	 */
	private int utilisedTime;

	protected ResourceProfileEntry() {
		super();
	}

	public ResourceProfileEntry(String dateKey) {
		super(dateKey);
	}

	@Override
	public String toString() {
		return "ResourceProfileEntry for " + getDateKey() + ", utilised " + Integer.toString(utilisedTime);
	}

	public int getUtilisedTime() {
		return utilisedTime;
	}

	public void setUtilisedTime(int utilisedTime) {
		this.utilisedTime = utilisedTime;
	}

	/**
	 * Allocates specified amount of work and returns the total utilised time
	 * 
	 * @param allocatedWork
	 * @return
	 */
	public int allocateWork(int allocatedWork) {
		utilisedTime = utilisedTime + allocatedWork;
		return utilisedTime;
		// return firstAvailableTime().getTime();
	}

	@Override
	public void clear() {
		utilisedTime = 0;

	}

}
